/* eslint-disable @typescript-eslint/no-explicit-any */
import { post, customError } from '../index';
import { ReturnType, UserResponse, TelegramLoginRequest } from '../interface'
import { URL_RECAPTCHA, URL_START, URL_USER_INFO } from '../base/url'


export const telegramLogin = async (data: TelegramLoginRequest): Promise<ReturnType<UserResponse | undefined>> => {
    try {
        const result = await post<UserResponse>(URL_USER_INFO, undefined, { 'init-data': data.initData })
        return result;
    } catch (error: any) {
        return customError(error)
    }
}

export const startDig = async (): Promise<ReturnType<undefined>> => {
    try {
        return await post(URL_START)
    } catch (error: any) {
        return customError(error)
    }
}

export const isHuman = async (params: { response: string }): Promise<ReturnType<{ success: boolean } | undefined>> => {
    try {
        return await post(URL_RECAPTCHA, params)
    } catch (error: any) {
        return customError(error)
    }
}


// export const saveContactInfo = async (params: SaveContactRequest): Promise<ReturnType<undefined>> => {
//     try {
//         return await post(URL_SAVE_COMMUNITY, params)
//     } catch (error: any) {
//         return customError(error)
//     }
// }